using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Business;
using Entity;
public partial class UserControl_PlanDetailManager : System.Web.UI.UserControl
{
    ePlanDetail planDetail;
    String type;
    int PlanDetailID;
    public UserControl_PlanDetailManager()
    {
    }

    public UserControl_PlanDetailManager(String PlanDetailID)
    {
        this.PlanDetailID = int.Parse(PlanDetailID);
        if (this.PlanDetailID != -1)
        {
            type = "Update";
        }
        else
        {
            type = "Addnew";

        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {

        dlPlan.DataSource = bPlan.getAllPlan();
        dlPlan.DataTextField = "planName";
        dlPlan.DataValueField = "planID";
        dlPlan.DataBind();

        if (type == "Update")
        {
            planDetail = bPlanDetail.getPlanDetailByID(PlanDetailID);
            btDelete.Attributes.Add("onclick", "return confirm('Are you Sure you want to delete this Plan')");

            loadForm(type);
        }
    }

    void loadForm(String typeView)
    {
      //  Response.Write("Plan load form");
        if (typeView == "Update")
        {
            btAdd.Text = "Update";
            txtPlanDetailID.Text = planDetail.PlanDetailID.ToString();
            txtPlanDetailName.Text = planDetail.PlanDetailName;
            txtPrice.Text = planDetail.PlanDetailPrice.ToString();
            txtPlandetailDescription.Text = planDetail.PlanDetailDescription;
            dlPlan.SelectedValue =planDetail.planID.ToString();
        }
        else
        {
            txtPlanDetailID.Text = "";
            txtPlanDetailName.Text = "";
            txtPrice.Text = "";
            txtPlandetailDescription.Text = "";

        }
    }
    protected void btAdd_Click(object sender, EventArgs e)
    {
        
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {

    }
    protected void btDelete_Click(object sender, EventArgs e)
    {

    }
    protected void btReset_Click(object sender, EventArgs e)
    {
        loadForm(type);
    }
}
